package com.huanying.goodjob.business;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.huanying.framework.BaseController;
import com.huanying.framework.PageBean;
import com.huanying.framework.user.UserController;
import com.huanying.framework.user.UserService;

@Controller
public class BusinessListController extends BaseController{
	@Autowired
	private BusinessListService businessListService;
	
	private static Logger logger = Logger.getLogger(BusinessListController.class);
	@RequestMapping(value = "/show_business.do")
	public String show_business(String name,String shopname,String page_num, Model model) throws Exception {
        PageBean pageBean = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put("name", name);
		map.put("shopname", shopname);
		
		if (page_num == null) {
			page_num = "1";
		}
		try {
		     pageBean = businessListService.searchBusiness(map,super.getPageSize(), Integer.parseInt(page_num));
		     logger.info("查询展示工单信息成功");
		} catch (NumberFormatException e) {
			logger.error("查询展示工单信息失败", e);
			//e.getMessage();
		} catch (Exception e) {
			logger.error("查询展示工单信息失败", e);
			//e.getMessage();
		}		
		model.addAttribute("name",name);
		model.addAttribute("shopname",shopname);
		model.addAttribute("businesslists", pageBean.getList());
		model.addAttribute("page",pageBean);
		return "business/add_business";
	}

}
